This code was moved across from the old implementation. I feel we should be using a central lib for these `bytes` => `pixels` and `pixels` => `bytes`.