You don't.
It's the other guy's option, and he will exercise the option in the way that is most profitable to him (not to you). You sold him a right, and now you are at his mercy.
In some sense, you already got the dividend when you wrote the option, since the ex-dividend event was taken into account in the option pricing at that time.