'Reads a chunk from the file object.
Params are passed directly to the underlying file object\'s read().
:returns: Compressed chunk from file object.'

def read(self, *a, **kw):

    if self.done:
        return ''
    x = self._f.read(*a, **kw)
    if x:
        self.crc32 = (zlib.crc32(x, self.crc32) & 4294967295)
        self.total_size += len(x)
        compressed = self._compressor.compress(x)
        if (not compressed):
            compressed = self._compressor.flush(zlib.Z_SYNC_FLUSH)
    else:
        compressed = self._compressor.flush(zlib.Z_FINISH)
        crc32 = struct.pack('<L', (self.crc32 & 4294967295))
        size = struct.pack('<L', (self.total_size & 4294967295))
        footer = (crc32 + size)
        compressed += footer
        self.done = True
    if self.first:
        self.first = False
        header = '\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff'
        compressed = (header + compressed)
    return compressed
