Firstly, with regard to your confusion about Pan, she was born in the Age 779. This is after the Age 778 when the Battle of Gods arc first takes place and Videl is pregnant. Goku leaves to train with Uub in the Age 784. So yes! It is possible for Pan to be four during the final events of DBZ.
With regard to your main question, the answer would be yes and no. The reason I say that is because if you were to take DBZ and DBS as a whole and look at the events, it does make sense in a way and seems canon so you could consider it to be canon. As the same ending of Goku going to train with Uub can be found in both the manga and the anime, you can't necessarily consider it to be filler.
However, the reason I said the answer could be yes and no, is because the DBS series was thought off after a significant amount of time. Over the years, for the purpose of extending the series, a lot of prior information has been retconned simply for the purpose of convenience. For instance, DBS Broly retcons the original series of Dragon Ball with regard to Goku's age. The character of Broly was re-introduced and dramatically changed. The power scaling of characters increased dramatically. Currently, the manga is working on a chapter after the events of DBS Broly and the T.O.P, and we don't know whether the series is going to resume or whether we are going to see several more arcs after which replace the Martial Arts Tournament that takes place
The reason I say this is because the only reason Goku entered the tournament was because he was very excited to fight Uub (Kid Buu). Kid Buu was basically one of the strongest antagonists in DBZ whom Goku lost against, so it would make sense for him to be excited to fight him. Goku has clearly fought several antagonists much superior to Kid Buu over the years in DBS and it wouldn't make sense why he'd be as excited to fight someone several times weaker. That said, Goku is excited to fight anyone most of the time so the ending could still exist.
In conclusion, if you take the series as a whole now, yes! The ending can be fit in. However, it could very easily be retconned if the series were to resume.