If a job applicant has accepted an offer only to later accept a position with another company, a letter withdrawing from consideration is in order immediately. This letter includes thanks and a wish of luck in finding a better candidate.
Dear Mr./Ms. Bossname,
Thank you again for extending the offer to serve as (position) with (company). I enjoyed meeting you and learning more about the company. Unfortunately, I must withdraw my name from consideration.
When we spoke (date), I mentioned that I was exploring options with other firms. As it turns out, I was offered a position with another company. It's a good match and one I can't pass up. I accepted the position (today/yesterday).
I appreciate your kindness and consideration and wish you the best in finding the best candidate for the job.