Issue #1779718 by rooby: Fix bug causing filenames with spaces to save incorrectly on certain systems.