recursive directory creation

If a supplied path for the output file does not exist, the subfolders
are automatically created