Fix #294: "Output file permission issue". Not the cleanest solution, but it will work for all cases.
Merge branch 'hotfix/fileperms'