Use tempfile for CopyFileWithTar

Fixes #1922