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

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

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