Allow specification of a default output folder.

Also add better error checking of file paths.