If you call z.flush();z.write('foo'); then it would try to write 'foo' before the flush was done, triggering an assertion in the zlib binding. Closes #4950