fix sampling and add image generation