Fixes #672, explicitly checks type of opts.input_dir

If output_dir is specified, uses that output_dir.

If output_dir is not specified, checks input_dir type:
- if it is a file, uses os.path.split to get the containing directory and uses it as output_dir
- if it is a directory, sets output_dir = input_dir