Make sure we create directories for files in subdirectories

Fixes #430