write to temp file when downloading