When downloading a file, check first that the parent directory structure exists first
When downloading a file, check first that the parent directory structure exists first. Otherwise, we'll get an I/O error when writing the file to the local filesystem.
Fixes #22 (closed).