Fix EPERM error on Windows on rename

Fixes #83 by writing to output file on callback