Cleanup on image rendering code. Now takes byte array as input.