Strong Character is the Key
Given all of the difficulties Tom has had, and the sudden absolute power he achieves, one things helps him to remain a good person rather than turning into somebody evil like the gang members. That one thing is his strong, moral character: he has virtues (honesty, humility, courage, kindness, etc) and these determine his choices.