Gallinari scores 22 as Nuggets beat Nets 123-115