Use makedirs

So that it works even with deep paths.