Cleansing the Mind

What does it mean to "cleanse the mind?" We must put out all unpure thoughts, but how?