Suport Grayscale, 216 and 256 color output modes.

Ported from the C version of Termbox.