I am an overcomer in this area.
First repent (are you truly sorrowful over your sin?) and pray for deliverance. Then take away all the things that causes the temptation. Books, magazine, tv, movies, etc. This was one of my major causes of temptation.
In Romans 12:2 the Bible tells you not to be conformed to this world,
"but be ye transformed by the renewing of your mind that ye may prove what is that good, and acceptable, and perfect, will of God."
Also to refrain from all appearance of evil...
I Thessalonians 5:22 Abstain from every form of evil.
Be watchful of what you think about. If you catch yourself thinking about it, pray and switch your train of thought. God wants our thought life to be pure...
Hebrews 4:12 For the word of God is living and powerful, and sharper than any two-edged sword, piercing even to the division of soul and spirit, and of joints and marrow, and is a discerner of the thoughts and intents of the heart.
Jesus, in His explanation of "Thou shalt not commit adultery", told us that adultery begins in the mind, when someone lusts after another person (Matthew 5:28). If we let God control our mind, we can fight sin at its very root.
Luke 6:45 A good man out of the good treasure of his heart brings forth good; and an evil man out of the evil treasure of his heart brings forth evil. For out of the abundance of the heart his mouth speaks.
Jesus taught it was not the kind of food or drink that defiled a man, but what came out that defiles...
Mark 7:20-23 And He said, What comes out of a man, that defiles a man. 21 For from within, out of the heart of men, proceed evil thoughts, adulteries, fornications, murders, 22 thefts, covetousness, wickedness, deceit, lewdness, an evil eye, blasphemy, pride, foolishness. 23 All these evil things come from within and defile a man.
Sin begins in the mind...
James 1:12-15 Blessed is the man who endures temptation; for when he has been approved, he will receive the crown of life which the Lord has promised to those who love Him. 13 Let no one say when he is tempted, I am tempted by God; for God cannot be tempted by evil, nor does He Himself tempt anyone. 14 But each one is tempted when he is drawn away by his own desires and enticed. 15 Then, when desire has conceived, it gives birth to sin; and sin, when it is full-grown, brings forth death.
Begin to fill your mind with the treasures of Christ...
Colossians 3:16 Let the word of Christ dwell in you richly in all wisdom, teaching and admonishing one another in psalms and hymns and spiritual songs, singing with grace in your hearts to the Lord.
Ephesians 5:19 speaking to one another in psalms and hymns and spiritual songs, singing and making melody in your heart to the Lord,
The word of Christ should dwell in you richly. This can be accomplished by
regular bible reading ,
study and meditation in the Bible, by
memorizing Scriptures,
by church attendance, and
through committed obedience to Christ's teachings.
Philippians 4:8 Finally, brethren, whatever things are true, whatever things are noble, whatever things are just, whatever things are pure, whatever things are lovely, whatever things are of good report, if there is any virtue and if there is anything praiseworthymeditate on these things
"For as he thinketh in his heart, so is he." - Proverbs 23:7