Generate directory structure for output file if needed.
Merge pull request #17 from AMeng/generate-dirs-for-output

Generate directory structure for output file if needed.