Much like any other temptation, the Lord has to train us on how to overcome it. It's never easy, but worth it in the long run. I was addicted to porn for over 13 years, and today all my computers are completely clean from that garbage thanks be to Jesus!
I totally agree with the others in seeking out help and prayer. Remember you are far from being alone in this type of struggle. Also I will throw in some my insights.
The Lord lead me to the perception and fact my body is not my own.
1 Corinthians 6:18-20 (NIV)
18 Flee from sexual immorality. All other sins a person commits are outside the body, but whoever sins sexually, sins against their own body. 19 Do you not know that your bodies are temples of the Holy Spirit, who is in you, whom you have received from God? You are not your own; 20 you were bought at a price. Therefore honor God with your bodies.
Now remember God created sex, but it was meant for marriage. With that fact, my body is not my own but my wife's. I am not made to be self gratifying myself, but to give myself(sacrifice) to my wife and God.
During my struggles, one of the hardest things to learn and accept is Jesus in the middle of my sexual thoughts. For a long time I was way too embarrassed to put the two together.
Later I found I could relate to Paul. He wasn't perfect at all, and he too had to struggle with his sin. One of things he wrote perplexed me.
Romans 7:21-25 (NIV)
21 So I find this law at work: Although I want to do good, evil is right there with me. 22 For in my inner being I delight in Gods law; 23 but I see another law at work in me, waging war against the law of my mind and making me a prisoner of the law of sin at work within me. 24 What a wretched man I am! Who will rescue me from this body that is subject to death? 25 Thanks be to God, who delivers me through Jesus Christ our Lord!
So then, I myself in my mind am a slave to Gods law, but in my sinful nature a slave to the law of sin.
Finally the Lord lead me to the revelation that I need his strength to overcome the temptations of the 'sinful nature'. There is no shame in call on the name of Jesus when you recognize the attack.
Now know there is a part of you, the 'sinful nature' or 'left hand'(by Jesus/Solomon) that will lead you into sin. Our heart can be easily influenced by words and especially by pictures. (which is why advertisements are all over the place, to persuade you to buy a product or service) Same thing with sin.
Jesus made it clear what to do.
Matthew 5:27-30 (NIV)
27 You have heard that it was said, You shall not commit adultery.[a] 28 But I tell you that anyone who looks at a woman lustfully has already committed adultery with her in his heart. 29 If your right eye causes you to stumble, gouge it out and throw it away. It is better for you to lose one part of your body than for your whole body to be thrown into hell. 30 And if your right hand causes you to stumble, cut it off and throw it away. It is better for you to lose one part of your body than for your whole body to go into hell.
Not literally removing our body parts, but things in our lives that influence us to sin. I had to toss out my computer out more than once. There are many placings I can't go into. I can't look at women with revealing features. Whatever is used against you, needs to be removed or avoided.
Now this is from personal experience. I learned that whenever an image or a term/phrase or a memory from my many years of garbage. I can rebuke them in the name of Jesus and the Lord can destroy the images/thoughts that come against me. Takes lot persistence and prayer, but once you discover that God can 'delete' things you see during your day that needs to be destroyed. It will be a powerful weapon in staying out of temptation.
Remember the Devil can remind you of something you shouldn't have saw and use it as ammunition. Best to destroy any evil images before it comes back to haunt you.
Sorry for the lengthiness. I pray what I shared with you will help you and others grow strong in the Lord in this area.