Make `--out` to create parent directories

Fix #1389.

I don't sure this should be treated as a new feature.
Btw, I prefer the use of `mkdir_p` instead of `makedirs` (`makedirs` is just an alias for `mkdir_p`).