Separate extension detection from format flag checking

Should make the flow of logic clearer in the format selection code.
Add error detection if multiple formats selected

Specifying multiple formats at once will now raise an error. I'm trying to
think of a better way to test for this, but haven't got any ideas yet.