Set temp file extension to source file extension

Unless an extension can't be extracted, in which case the current usage of grammar name for file extension will be used.  Basically, I ran in to an issue with a linter not being happy unless the extensions matched with the expected filetype.