Basic PGM image processing with Java