Autodetect output type based on file extension
Rudimentary tests