add -M to make the image as managed

Needs to have error catching added.