refactored file uploads to support Tempfile