fixed template extension in template.write()