Fixing DistCopy - flush stream before moving tmp file

@raronson @charleso 
Yeh, it will be a bit of rework, but worth it I think.