safe bool casting
only convert for ncolors<=256
make PIL optional