improve converting image and return array of pixels instead of jpg