Also save the output file format to settings.
Removed useless code
Improve automatic file extension handling
Fix build.
Remove duplicate code.