Nah, masturbation is actually pretty good for you, physically and psychologically. God's not going to punish you for whatever you imagine while you're wanking. If that was Her aim, She would not have given us so little control over what we do or don't think about, and She wouldn't have given us a smorgasbord of hormones that force us to be horny, even when we'd rather not be, and She wouldn't have made orgasms pretty much the only effective remedy for horniness.
If you are looking for more control over your sexual thoughts and urges, meditation can be somewhat effective, from what I understand. It's not based on the idea that you try to suppress / repress / eliminate your sexual urges, but you let them arise, take note of them as a casual observer rather than a slave to them, and wait for them to pass naturally, as they inevitably will. (Because all things pass). From that frame of mind, you needn't be disturbed by your horniness and you needn't do anything about it. It just is. Like all feelings, horniness comes and goes, so to speak.