Make `--out` to create parent directories

Fix #1389.