You gotta realize, you're the only one thinking those thoughts. You're the one who is judging yourself, they are not judging you. And by judging yourself, you're starting to believe you're not a good person. And by believing you're not a good person, you start to come to more negative conclusions about yourself. So all of your misery is simply coming from yourself... nothing else.
Try to look at that rationally and see how ridiculous it is. Not that I'm saying you're ridiculous, like ThatGuyInThere said we've all been there. You just gotta see the negative cycle for what it is and break it.
Just whenever you start getting any negative thoughts creeping in like that, remember they are just voices... and you don't have to listen to them... however if you do listen to them, things will get much worse for you, as you can see that's already happened, considering you now believe you're a bad person. Of course, if you ignore them and only focus on the positives, you'll start to build confidence back in the positive direction so you no longer have those voices keeping you down.