Noor sent me something really good concerning this when i asked about whether or not i was a sin to just THINK 'dirty' Or 'bad' thoughts :
"What to do when a bad thought occurs to you
Whenever a bad thought occurs to you:
a) seek Allah’s forgiveness [saying, Astaghfirullah (‘I seek Allah’s forgiveness’)];
b) seek protection from the Shaytan [saying, A`udhu billahi min ash-shaytan ar-rajeem (‘I seek refuge in Allah from the accursed shaytan’)]
c) cut out the things that result in that bad thought immediately [e.g. shut the window with such images]
d) then thank Allah, wholeheartedly, for enabling you to overcome your desires and shaytan [saying, Alhamdulillah (‘All praise is due to Allah’)]; this makes Shaytan despair, and strengthens one’s resolve.