refactor tempfile method
fixing problem with remote executions
.