Optionally use mkdirp to ensure output destination directory exists. Fixes #1099