Hi! As someone who's struggling with the same issues as you, I thought I'd share some of my insights in the matter. I hope they can help you! Picture related, because I thought you could use a hug. (I apologize for the possible typos, which are due to a combination of a new laptop keyboard, as well as the rambling, which is due to me being a derp)
Look, it's very simple. Pedophiles /want/ to have sexual conduct with children. They see it in a positive light, and see nothing wrong with it. If you don't, then you're not a pedophile. Having thoughts about something is not the same as wanting it. You've got nothing to fear, amigo.
As for the porn? Well, think of it this way. Some people, through birth, through nurture or just f-ed up odds, have some weird stuff in their brains. It's not exactly related to what they really want, it's just some obsessive-compulsive "brain bug" or summat. And they might have a compulsion to look up weird porn and masturbate to it, just to appease that brain bug. As long as you're aware of it and don't do what it wants, you'll be cool.
Also, there's nothing wrong with masturbation, as long as you're getting off to stuff you like instead of the brain bug. Masturbation's a normal and healthy thing, don't feel like it's somehow filthy because of these thoughts. Just try to disconnect yourself from them and keep doing your own thing.
To use a (pretty gross) extended metaphor: The brain is a city, your personal city. And on its streets, there are puddles of vomit. They've always been there, but you haven't really noticed before. They're stuck on the streets, and they can't really be scrubbed away. But the vomit is not the city, nor is it the streets. It's simply a part of them.
Sometimes, you'll step into the puddles. Sometimes, you can avert them in time, because no one really wants to step into. Sometimes, you'll see the puddles coming, but you might absent-mindedly walk into them anyway. Or, trying to walk around, you trip and fall face-first into the vomit. Sometimes, you might walk away from a puddle only t