Trim whitespace from filenames on save

Issue #2331