Fix an issue where extensions containing multiple periods (dots, '.') would result in wrong filenames