Add compression support for WriteStream and ReadStream.

* To support this a close() method was added to the WriteStream interface. This is needed because otherwise there is no way to know once the complete data was written and a pending footer needs to be written.