I have been here for a few minutes reading and have yet to hear a tiny bit of faith on this thread. I am going to attack this from a few different angles so I pray that this comes out in a way that you can follow and that it helps.
I used to touch and watch pornography consistently. I am not saying that you are addicted as I was but I want to share something to show you how powerful the name Jesus Christ is before I go into details about the issues you have posted about. I tried so hard to stop for years. I tried everything that everyone above me has listed, as well as things they have not listed and nothing helped. Until one day when I truly honestly poured out my heart to Jesus and told him that I couldnt do it anymore on my own... I needed him to take it and do it for me. And the next day... My urge wen't away. I tried years on my own... and then I honestly truly ask Jesus for help and Bam... its gone. I still get tempted daily... but it does not control me nor do I give into it... Thanks to Jesus. He can do everything... we can't do anything on our own. A lot of the comments above has listed man made tips to try to help but non will... You need help that only Jesus can provide. So before you take advice from anyone on this thread... including myself... You pray, and you ask Jesus for him to take it away from you if you really want it gone, and then you immediately believe that he has already done it...and it is done. For his word says that "Whoever so prays for something justly, and believes that he has recieved it will so recieve it" (I summarized what it says)
Now, you talked about being lonely... now this is a problem we all face. However, finding someone who loves you (A Partner) will not answer this. A partner is not all hugs and kisses as we always imagine. It is SERIOUS work and my firm belief is that to have a great relationship we first need to be great on our own through and with Jesus. Remember that we should ENJOY single-ness because once marriage comes along... single-ness is officially over. Marriage and having a partner is forever, single-ness isnt. Now, to tackle your loneliness my obvious answer is to pray heavily on it because prayer answers all. However, the word says that he that does not work does not deserve to eat... therefore while we pray, we need to put effort for Jesus to guide us. Do you attend service weekly? Are you part of a church? Does your church have a youth group where you can meet friends and attend events with them? Have you went to youth groups at your school? If you dont attend a youth group or a church why havn't you looked for one?
Answer those questions and then if you cannot find the answer to why you are lonely then message me again and we can dig deeper but I feel that those might show you some light.
In regards to your masturbation. Most christians would say that it is a sin. I am not here to preach but I am only stating my opinion from what I read, have been told, and found for myself (I am part of an inter-demoninational church which means that we are basically Christians... no added fluff. Called Times Square Church ... you can check us out if you want to see where I am coming from). Now, I do believe that masturbation is a sin... and I will explain why.
Masturbation itself is probably NOT bad... however, what masturbation causes you to do normally is very bad. Normally, when people touch they usually have sexual thoughts going on, watch porn, imagine the real thing, imagine someone, think of someone, think of doing things to someone or a past encounter... ALL of those are sins. Jesus said that if you look at someone and think lust-fully you have already sinned... so therefore thinking sexual thoughts of that sort is a sin... you cannot argue that one bit. It doesnt mean we dont get sexual thoughts... but giving into them is a whole different thing. If you can touch WITHOUT any of that which I wrote above... then cool, you are fine. However I CAN BET that 99.9 percent of people can't... Which makes masturbation wrong. As well if it eventually leads you into those things.
To solve your problem of masturbation... Again honest true prayer is the answer, and then believing it. If you pour your heart out you will see that you won;t need a "Game Plan" on how to quit... Jesus will make you stop cold turkey.
I think that my honest opinion is that you need to fellowship because it will occupy your time. So I think that praying for good friends, ministry to join, events to go to, the ability to enjoy your single life while you have it, and to stop your masturbation sinning is the first step. And if you dont think you can honestly pray for any of those yet you should pray for the ability to want those things.
Secondly, meet people and join events. If you go to a church, you have all the tools right there. If you don't, look online and find a church near you with a good youth team.
You are on the right path, don't give up. Have faith in God and finish the race in prayer.