Better infrastructure support for 16 bit images

Fixes #163.