Place tempfile in the directory of the file