Avoid Race Conditions around Saving Input and Output Files

It is guaranteed that a call to the close() method of a file object will
eventually flush the write buffer to the disk, but it is not guaranteed
that this will happen before the method returns. In particular, if a
task finishes too quickly, the worker will close the output file, report
the task as finished, the manager will try to read a file that is not
guaranteed to exist.

According to http://docs.python.org/2/library/os.html#os.fsync the
correct way to guarantee the existence of a file is doing flush() ->
os.sync() -> close() as implemented in this patch.
Merge pull request #1 from dMaggot/master

Avoid Race Conditions around Saving Input and Output Files