fixed an image leak
fixed an updating pgm bug