write to .tmp file when downloading
fix bug: channel closed
fix adding tmp file bugs