Add fifth argument to specify bits per pixel for grayscale images