bug fixes: failed to write file larger than 4096 bytes