I think the best thing you can do is to make sure you sleep well, as this will keep your willpower levels high. The other thing would be to start meditating as it will strengthen your frontal cortex, which is in charge of decision making. The last thing I can say is to avoid the places where you tend masturbate and keep yourself busy as much as possible. The idea is that you sublimate sexual desire through an artistic or intellectual pursuit.