Quick update so tests pass on Mac

Converts backslashes in output dirs to forward slashes before passing
to path.join(), which doesn't handle backslashes on non-Windows
platforms.
Generalize writing input files to an output stream.