Evil thoughts especially when they are not within a person's control are not considered sins. The best way to rid yourself of these thoughts is to absolutely ignore them. They will become less and less until they fade away completely. They are not really what you think but something that just crosses your mind and they should be treated as such. If it has reached the stage when you cannot help making yourself think these things then again the best remedy is not to punish yourself at all, but to completely ignore them as if they did not even occur. Over time it will pass.
May you always be successful