I'm not saying this will work for everyone, but recently I've started snapping a rubber band on my wrist every time I think about porn.
The rubber band fits comfortably around my wrist and two or more small, but painful snaps quickly gets me off the subject. So, far it's stopped me from relapsing about two times. I'm cautious to avoid bruising myself and making sure that I only punish thoughts of porn not sexual thoughts. I'm trying to retrain my brain to focus on real people and ideas not porn.
Wish me luck?
EDIT — I should note that using this method has kept me from viewing porn for an entire week. I'm still tempted, but the snapping pulls me out my craving long enough to remember why I'm quitting porn. I'll wear this rubber band my whole life if I have to