Allow P2G to accept dimensions other than Z and to handle 16bit values

In order to generate Intensity images, we need to be able to pass Intensity values (16bit) rather than Z values to p2g