Encode invalid characters in filenames.