Copied stuff from Piston copied 'TEMP-rust-png' code