Added a more accurate check of directory detection from input file path along with ability to create missing directories when any output path does not exist on disk. This will allow us to provided arbitrary path in output locations, such as `exportmap` option.
Added ability to write to file. Needs refactor and cleanup.