Encode filenames

I had an error when trying to upload my files. This is the error:

    <?xml version=\"1.0\"?>\n<ErrorResponse xmlns=\"http://cloudfront.amazonaws.com/doc/2010-11-01/\"><Error><Type>Sender</Type><Code>InvalidArgument</Code><Message>Your request contains one or more invalid invalidation paths.</Message></Error><RequestId>04705081-4e05-11e4-8882-43cbc738add4</RequestId></ErrorResponse>

I'm almost completely sure it's due to me having filenames with spaces in them.