Fixing DistCopy - flush stream before moving tmp file

@raronson @charleso 
Just to confirm - it was intentional to use the "outer" in/out streams?