Keep it DRY using img_to_array and array_to_img