       @write chunk
     
     if @deflate
+      @deflate.write(Buffer.concat(@chunksToCompress));
       @deflate.end()
     else
       @finalize()

    
    if @compress
      @initDeflate() if not @deflate
      @deflate.write chunk
    else
      @chunks.push chunk
      @data.Length += chunk.length

    @compress = @document.compress and not @data.Filter
    @uncompressedLength = 0
    @chunks = []
    @chunksToCompress = [];
    
  initDeflate: ->
    @data.Filter = 'FlateDecode'
