         mask.push x, x
 
       @obj.data['Mask'] = mask
-      
+
     else if @image.transparency.indexed
-      # Create a transparency SMask for the image based on the data 
+      # Create a transparency SMask for the image based on the data
       # in the PLTE and tRNS sections. See below for details on SMasks.
       @loadIndexedAlphaChannel()
-      
+
     else if @image.hasAlphaChannel
       # For PNG color types 4 and 6, the transparency data is stored as a alpha
       # channel mixed in with the main image data. Separate this data out into an
       # SMask object and store it separately in the PDF.
       @splitAlphaChannel()
-      
+
     else
       @finalize()
-      
+
   finalize: ->
     if @alphaChannel
       sMask = @document.ref


      # build the color space array for the image
      @obj.data['ColorSpace'] = ['Indexed', 'DeviceRGB', (@image.palette.length / 3) - 1, palette]
      
    # For PNG color types 0, 2 and 3, the transparency data is stored in
    # a dedicated PNG chunk.
    if @image.transparency.grayscale

      zlib.deflate alphaChannel, (err, @alphaChannel) =>
        throw err if err
        @finalize()

module.exports = PNGImage
