implement WriteStream with block chunking
Code cleanup