add image scaling and better encoding