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