We can set two equations to solve the question:
Let Gary's age be x and his brother's age be y.
As Gary is 8 years older:
x+8 = y
x = y-8...(1)
Six years ago Gary was three times as old as his brother:
x-6=3(y-6)...(2)
Put (1) into (2)
y-8-6 = 3y -36
-2y = -36+14
y = -22/-2
y=11
His brother is 11 years old, while the age of Gary:
11+8=19
Hope it helps!