Fix off-by-one error when handling bg colours.

Fix for #170