Ensure files have write permissions when necessary during temp file creation/deletion

- Fixes issue with Perforce source control (files are read-only until checked out)
- Original permissions are restored on original file after temp file deletion
Merge pull request #181 from emr4378/master

Ensure files have write permissions when necessary during temp file creation/deletion