To have a pure heart, we must submit all thoughts to the authority of Christ. If we are willing to do that, he will change us to be like him.
A nun I know once told me she kept begging God to take her character defects away from her. After years of this prayer, God finally got back to her: I'm not going to take anything away from you, you have to give it to Me.