diff --git a/SOURCES/python-pillow-2.0.0_bytearray.patch b/SOURCES/python-pillow-2.0.0_bytearray.patch
new file mode 100644
index 0000000..1b8d2f0
--- /dev/null
+++ b/SOURCES/python-pillow-2.0.0_bytearray.patch
@@ -0,0 +1,37 @@
+diff --git a/PIL/Image.py b/PIL/Image.py
+index cafc5a2..794ee49 100644
+--- a/PIL/Image.py
++++ b/PIL/Image.py
+@@ -718,7 +718,7 @@ class Image:
+         if self.mode == "L" and mode == "RGBA" and "transparency" in self.info:
+             from PIL import ImagePalette
+             self.mode = "P"
+-            bytePalette = bytes([i//3 for i in range(768)])
++            bytePalette = bytes(bytearray([i//3 for i in range(768)]))
+             self.palette = ImagePalette.raw("RGB", bytePalette)
+             self.palette.dirty = 1
+             self.load()
+diff --git a/_imaging.c b/_imaging.c
+index 2ee7eef..6ec7346 100644
+--- a/_imaging.c
++++ b/_imaging.c
+@@ -286,6 +286,7 @@ static const char* wrong_mode = "unrecognized image mode";
+ static const char* wrong_raw_mode = "unrecognized raw mode";
+ static const char* outside_image = "image index out of range";
+ static const char* outside_palette = "palette index out of range";
++static const char* wrong_palette_size = "invalid palette size";
+ static const char* no_palette = "image has no palette";
+ static const char* readonly = "image is readonly";
+ /* static const char* no_content = "image has no content"; */
+@@ -1412,6 +1413,11 @@ _putpalette(ImagingObject* self, PyObject* args)
+     return NULL;
+     }
+ 
++    if ( palettesize * 8 / bits > 256) {
++    PyErr_SetString(PyExc_ValueError, wrong_palette_size);
++    return NULL;
++    }
++
+     ImagingPaletteDelete(self->image->palette);
+ 
+     strcpy(self->image->mode, "P");
diff --git a/SOURCES/python-pillow-2.0.0_memleaks.patch b/SOURCES/python-pillow-2.0.0_memleaks.patch
new file mode 100644
index 0000000..366cec7
--- /dev/null
+++ b/SOURCES/python-pillow-2.0.0_memleaks.patch
@@ -0,0 +1,37 @@
+Index: python-imaging-Pillow-d1c6db8/libImaging/Antialias.c
+===================================================================
+--- python-imaging-Pillow-d1c6db8.orig/libImaging/Antialias.c
++++ python-imaging-Pillow-d1c6db8/libImaging/Antialias.c
+@@ -216,6 +216,7 @@ ImagingStretch(Imaging imOut, Imaging im
+                     break;
+                 default:
+                     ImagingSectionLeave(&cookie);
++                    free(k);
+                     return (Imaging) ImagingError_ModeError();
+                 }
+         }
+@@ -295,6 +296,7 @@ ImagingStretch(Imaging imOut, Imaging im
+                     break;
+                 default:
+                     ImagingSectionLeave(&cookie);
++                    free(k);
+                     return (Imaging) ImagingError_ModeError();
+                 }
+         }
+Index: python-imaging-Pillow-d1c6db8/libImaging/UnsharpMask.c
+===================================================================
+--- python-imaging-Pillow-d1c6db8.orig/libImaging/UnsharpMask.c
++++ python-imaging-Pillow-d1c6db8/libImaging/UnsharpMask.c
+@@ -141,8 +141,10 @@ gblur(Imaging im, Imaging imOut, float f
+     /* don't bother about alpha/padding */
+     buffer = calloc((size_t) (im->xsize * im->ysize * channels),
+ 		    sizeof(float));
+-    if (buffer == NULL)
+-	return ImagingError_MemoryError();
++    if (buffer == NULL) {
++        free(maskData);
++        return ImagingError_MemoryError();
++    }
+ 
+     /* be nice to other threads while you go off to lala land */
+     ImagingSectionEnter(&cookie);
diff --git a/SPECS/python-pillow.spec b/SPECS/python-pillow.spec
index a8af556..6f2e9d4 100644
--- a/SPECS/python-pillow.spec
+++ b/SPECS/python-pillow.spec
@@ -23,7 +23,7 @@
 
 Name:           python-pillow
 Version:        2.0.0
-Release:        12%{?snap}%{?dist}
+Release:        17%{?snap}%{?dist}
 Summary:        Python image processing library
 
 # License: see http://www.pythonware.com/products/pil/license.htm
@@ -38,6 +38,8 @@ Source0:        https://github.com/python-imaging/Pillow/tarball/%{commit}/pytho
 Patch0:         python-pillow-archs.patch
 # Fix test hardcoded for little-endian
 Patch1:         python-pillow_endian.patch
+Patch2:         python-pillow-2.0.0_bytearray.patch
+Patch3:         python-pillow-2.0.0_memleaks.patch
 
 BuildRequires:  python2-devel
 BuildRequires:  python-setuptools
@@ -203,6 +205,8 @@ PIL image wrapper for Qt.
 %setup -q -n python-imaging-Pillow-%{shortcommit}
 %patch0 -p1 -b .archs
 %patch1 -p1 -b .endian
+%patch2 -p1 -b .byte_array
+%patch3 -p1 -b .memleaks
 
 %if %{with_python3}
 # Create Python 3 source tree
@@ -360,6 +364,19 @@ popd
 %endif
 
 %changelog
+* Fri Feb 21 2014 Michal Minar <miminar@redhat.com> 2.0.0-17gitd1c6db8
+- Wiped out some memory leaks.
+
+* Fri Jan 24 2014 Daniel Mach <dmach@redhat.com> - 2.0.0-15.gitd1c6db8
+- Mass rebuild 2014-01-24
+
+* Tue Jan 14 2014 Michal Minar <miminar@redhat.com> 2.0.0-14gitd1c6db8
+- Fixed memory corruption.
+- Resolves: rhbz#1001122
+
+* Fri Dec 27 2013 Daniel Mach <dmach@redhat.com> - 2.0.0-13.gitd1c6db8
+- Mass rebuild 2013-12-27
+
 * Mon Jul 29 2013 Roman Rakus <rrakus@redhat.com> - 2.0.0-12
 - Mark doc subpackage arch dependent. Docs are built depending on supported
   features, which are different across archs.