updated image encoding