fixed bug where null bytes was written to save and template files