normalize pgm updated with ready to write output to the file