parameterize types, make this work with 16-bit PNGs