fix for PAM files when writing RGB, conversion RGB16->24/32

PAM writing for all RGB formats was broken (wrong max value of 256, it is in fact 255).

Also, conversion from RGB16 to RGB24 or RGB32 was also wrong due to a typo.
Merge pull request #120 from hwhw/fix-screenshot

fix for PAM files when writing RGB, conversion RGB16->24/32