write to tmp file during downloading