More robust method for creating the image directory