Move pixel format conversion to separate file