Make deploy script also create intermediate/dirs/to/target/dir

Before, we would only create the deploy target directory if its parent dir already existed. This patch makes it so that all of the intermediate directories are created too (if required).

Thanks @yyzhuang for reporting this issue!