Fixing DistCopy - flush stream before moving tmp file

@raronson @charleso 
Can this throw an error? Should it be wrapped in safe?