diff --git a/MagickCore/stream.c b/MagickCore/stream.c
index 2c0453b..5bd9832 100644
--- a/MagickCore/stream.c
+++ b/MagickCore/stream.c
@@ -619,8 +619,8 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  GetVirtualMetacontentFromStream() returns the associated pixel 
-%  channels corresponding with the last call to QueueAuthenticPixelsStream() or
+%  GetVirtualMetacontentFromStream() returns the associated pixel channels
+%  corresponding with the last call to QueueAuthenticPixelsStream() or
 %  GetVirtualPixelStream().
 %
 %  The format of the GetVirtualMetacontentFromStream() method is:
@@ -632,8 +632,7 @@
 %    o image: the image.
 %
 */
-static const void *GetVirtualMetacontentFromStream(
-  const Image *image)
+static const void *GetVirtualMetacontentFromStream(const Image *image)
 {
   CacheInfo
     *cache_info;
@@ -700,7 +699,7 @@
   if (cache_info->pixels == (Quantum *) NULL)
     {
       (void) ThrowMagickException(exception,GetMagickModule(),
-        ResourceLimitError,"MemoryAllocationFailed","`%s'",
+        ResourceLimitError,"MemoryAllocationFailed","'%s'",
         cache_info->filename);
       return(MagickFalse);
     }
@@ -737,7 +736,7 @@
       (columns == 0) || (rows == 0))
     {
       (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
-        "ImageDoesNotContainTheStreamGeometry","`%s'",image->filename);
+        "ImageDoesNotContainTheStreamGeometry","'%s'",image->filename);
       return((Quantum *) NULL);
     }
   cache_info=(CacheInfo *) image->cache;
@@ -856,6 +855,9 @@
   CacheInfo
     *cache_info;
 
+  MagickBooleanType
+    status;
+
   MagickSizeType
     number_pixels;
 
@@ -875,14 +877,14 @@
       (columns == 0) || (rows == 0))
     {
       (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
-        "ImageDoesNotContainTheStreamGeometry","`%s'",image->filename);
+        "ImageDoesNotContainTheStreamGeometry","'%s'",image->filename);
       return((Quantum *) NULL);
     }
   stream_handler=GetBlobStreamHandler(image);
   if (stream_handler == (StreamHandler) NULL)
     {
       (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
-        "NoStreamHandlerIsDefined","`%s'",image->filename);
+        "NoStreamHandlerIsDefined","'%s'",image->filename);
       return((Quantum *) NULL);
     }
   cache_info=(CacheInfo *) image->cache;
@@ -906,22 +908,32 @@
   cache_info->rows=rows;
   number_pixels=(MagickSizeType) columns*rows;
   length=(size_t) number_pixels*cache_info->number_channels*sizeof(Quantum);
+  if (length == 0)
+    length=number_pixels*sizeof(Quantum);
   if (cache_info->metacontent_extent != 0)
     length+=number_pixels*cache_info->metacontent_extent;
   if (cache_info->pixels == (Quantum *) NULL)
     {
-      cache_info->pixels=(Quantum *) AcquireAlignedMemory(1,length);
-      cache_info->length=(MagickSizeType) length;
+      cache_info->length=length;
+      status=AcquireStreamPixels(cache_info,exception);
+      if (status == MagickFalse)
+        {
+          cache_info->length=0;
+          return((Quantum *) NULL);
+        }
     }
   else
-    if (cache_info->length < (MagickSizeType) length)
+    if (cache_info->length < length)
       {
-        (void) RelinquishAlignedMemory(cache_info->pixels);
-        cache_info->pixels=(Quantum *) AcquireAlignedMemory(1,length);
-        cache_info->length=(MagickSizeType) length;
+        RelinquishStreamPixels(cache_info);
+        cache_info->length=length;
+        status=AcquireStreamPixels(cache_info,exception);
+        if (status == MagickFalse)
+          {
+            cache_info->length=0;
+            return((Quantum *) NULL);
+          }
       }
-  if (cache_info->pixels == (void *) NULL)
-    return((Quantum *) NULL);
   cache_info->metacontent=(void *) NULL;
   if (cache_info->metacontent_extent != 0)
     cache_info->metacontent=(void *) (cache_info->pixels+number_pixels*
@@ -1178,8 +1190,7 @@
         Prepare stream for writing.
       */
       (void) RelinquishAlignedMemory(stream_info->pixels);
-      stream_info->pixels=(unsigned char *) AcquireAlignedMemory(length,
-        sizeof(*stream_info->pixels));
+      stream_info->pixels=(unsigned char *) AcquireAlignedMemory(1,length);
       if (stream_info->pixels == (unsigned char *) NULL)
         return(0);
       (void) ResetMagickMemory(stream_info->pixels,0,length);
@@ -1312,7 +1323,7 @@
   if (quantum_map == (QuantumType *) NULL)
     {
       (void) ThrowMagickException(exception,GetMagickModule(),
-        ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
+        ResourceLimitError,"MemoryAllocationFailed","'%s'",image->filename);
       return(MagickFalse);
     }
   for (i=0; i < (ssize_t) length; i++)
@@ -1339,7 +1350,7 @@
           break;
         quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
         (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
-          "ColorSeparatedImageRequired","`%s'",stream_info->map);
+          "ColorSeparatedImageRequired","'%s'",stream_info->map);
         return(MagickFalse);
       }
       case 'g':
@@ -1362,7 +1373,7 @@
           break;
         quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
         (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
-          "ColorSeparatedImageRequired","`%s'",stream_info->map);
+          "ColorSeparatedImageRequired","'%s'",stream_info->map);
         return(MagickFalse);
       }
       case 'M':
@@ -1373,7 +1384,7 @@
           break;
         quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
         (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
-          "ColorSeparatedImageRequired","`%s'",stream_info->map);
+          "ColorSeparatedImageRequired","'%s'",stream_info->map);
         return(MagickFalse);
       }
       case 'o':
@@ -1402,14 +1413,14 @@
           break;
         quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
         (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
-          "ColorSeparatedImageRequired","`%s'",stream_info->map);
+          "ColorSeparatedImageRequired","'%s'",stream_info->map);
         return(MagickFalse);
       }
       default:
       {
         quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
         (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
-          "UnrecognizedPixelMap","`%s'",stream_info->map);
+          "UnrecognizedPixelMap","'%s'",stream_info->map);
         return(MagickFalse);
       }
     }
@@ -2629,7 +2640,7 @@
     {
       quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
       (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
-        "UnrecognizedPixelMap","`%s'",stream_info->map);
+        "UnrecognizedPixelMap","'%s'",stream_info->map);
       break;
     }
   }
@@ -2685,7 +2696,7 @@
   if (stream_handler == (StreamHandler) NULL)
     {
       (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
-        "NoStreamHandlerIsDefined","`%s'",image->filename);
+        "NoStreamHandlerIsDefined","'%s'",image->filename);
       return(MagickFalse);
     }
   length=stream_handler(image,cache_info->pixels,(size_t) cache_info->columns);