Ezekiel 18:23, 32
Do I take any pleasure in the death of the wicked? declares the Sovereign LORD. Rather, am I not pleased when they turn from their ways and live?
For I take no pleasure in the death of anyone, declares the Sovereign LORD. Repent and live!
God is just and rejoices when justice is served, which includes punishing those who have done wrong and aren't sorry about it. If God didn't punish evil, he would be unjust, which would be cause for his having sorrow and shame instead. Since God is just, he punishes evil, and can be satisfied that he has done the right thing. If the punishment would move the wrongdoer to repentence, he would also be pleased in the punishment's having that effect.
Yet God loves his creation and hates to see people suffer, even when it's the result of just punishment. When people, even evil people, feel the effects of punishment, God grieves for them. God desires what is best for everyone, and is further grieved when people don't do what is right and thus prevent him from blessing them and increasing their joy.
Hence God takes pleasure in doing what is right and executing justice, while simultaneously grieving over the evil that was done and the consequences of it for the evildoer. His pleasure is in the handing down of the punishment, and his pain is in watching it being carried out.
Related articles
See the articles about hell and God's wrath and punishment