Fix handling of '~' in output path