Add support for template files + solve an issue with mktemp