set format based on extension

There appears to be a bug where if you set the output file with extension and give an input file, the output file will be generated only as a pdf.  This is a quick fix to get it working, but don't know the script very well, so perhaps there's a better place to add this fix.