Fixed issue #1141 with invalid chars in filenames