Fix encoding and url encoding issues when uploading files