I've been training Bjj since 1998. I always learned to squeeze my knees to prevent this pain on testicles. This is the most common way to avoid this kind of injury.
But this year, when I was visiting the academy of the Master Sylvio Behring, he taught me a different approach for the arm lock (arm bar).
Squeeze your knees early. He told me to close my knees when my opponent arm are near to my knees and not near to my belly. This will create a much greater angle.
When you put the opponent's arm on your belly, the angle for the lock is shorter. Some guys with hyper-arm-extension can escape. When you lock your opponent's arm early, you have to use more of your arms to submit your opponent, but the angle is greater.
Another tip from the Master was to pull your opponent's head with your leg, to prevent him from biting your calf. This is because the Master teaches a lot of self defense as well and not just competition Bjj.
I don't know if I was clear enough with my explanation. To me, the Master was really clear and it was really nice to learn something basic from the Master.