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