If the safety valve is going off, it means that you have too much pressure in the boiler.
A few things you can do. First, ensure that your blower is off. Second, use the injectors to add a small amount of water. Adding cold water will cool the boiler, and hence drop the steam pressure (well, slow the rate at which steam is created, which in turn helps drop the pressure).
Also slow down on shoveling the coal as you near the top of the grade, since once you hit the top, you will be using less steam.
As a note, in Trainz, if the reverser is flashing yellow, it means you are working the locomotive too hard, and through this creating too much of a draft on the fire. This is causing your fire to be sucked through the boiler, which means you are not getting enough heat out of your coal before it disappears into the smokebox. If it is flashing, either reduce the cut-off (move the reverser/cut-off back toward neutral) or reduce the regulator
This next bit is just a bit of a helper based off some of the practices I've observed/experienced at Puffing Billy here in Melbourne (experience based off our stationary boiler, namely the range you want the water level between!). The rest is observation/discussions with those who have fired/driven the locos there, as well as a few who have fired on the mainline locos.
If you are going up grade, and using steam/water, lightly use the injectors on the way up. Keep the water level between 50-60% of the gauge glass. After you clear the top of the grade, and are coasting, you will not be using as much steam. By not using the injectors too much on the way up, you will give yourself room to add water on the way down. As you come down the grade, bring the water level up to 70-80%.
When driving steam locos, try not to exceed 70-80% on the gauge glass. Any more, and you will over fill the boiler (and this in turn lowers your steam pressure!). In reality, this would cause the locomotive to prime, which can blow your cylinder covers off. Not a good thing...
Hope this helps

Zec