Changed the file writing mechanism to support some filesystems (e.g. rackspace cloud files) that seems to not behave well with stream writing