Cleaned up how images are created to support if directory can't be written to.