Revert "cleanup"

This reverts commit 701a66413d47fc34aec9269dbf0bb19fb28e4359.
Revert "Replaced mktemp with alternative temp file generation based on secure randoms in order to avoid owner-restricted permission issues with mktemp files"

This reverts commit 640a88575a3f637ecdf6b6f677913020129aca04.
Set permission on copied file based on umask.