Fixes #769 - Change file paths to use a system-agnostic path to work with file uploads in Windows. Also made additional fixes to dealing with output streams and properly cleaning up if there were exceptions