Prevent writing zero-length buffers

Causes an issue with ZLib, where attempting to write nothing is an error
(as progress cannot be made).
Merge pull request #6 from dra27/null-write

Prevent writing zero-length buffers