Fix issue with image directory creation task race