Use mkpath instead of mkdir to create directories recursively.