When smiling for a photo, avoid the urge to say "cheese". The word actually stretches your mouth into an unnatural, unflattering smile. Instead, if you have a hard time smiling naturally, say words that end in "uh", like "mocha" or "yoga", to bring the corners of your mouth up naturally.
The video above is a little cringeworthy, but the tips themselves are sound. Words that bring your mouth into a natural smile are better if you have a hard time smiling for an impromptu photo. If that doesn't work for you, try to think of something funny. A laughing smile is almost always a better-looking one than a staged or forced one, so it's a good option.