Optimizing Prompts for Text-to-Image Generation