Fix output format detection to be more strict again

and also -f should override detection
Merge pull request #346 from presidentbeef/stricter_extension_format

Fix output format detection to be more strict again