create intermediate directories if necessary when copying images and files