Any Ideas On How To Keep My Lab/pit Mix Out Of The Cow Pastures?

My husband and I own two dogs…a 7mth old cockapoo (Pepper) and a 7mth old Lab/Pit mix (Bandit). They are both indoor dogs but they have to go out to potty, for walks and to play. This past week we were without electricity for over 5 days due to Ike and we spent alot of time outside with the dogs during the evenings to keep them from being too hot inside. One day, Bandit took off through the barbed wire fence into the neighbor’s pasture, and was having so much fun that we couldn’t get him to come back. Even funnier was that none of us could get past the barbed wire fence to get to him. Well, I wouldn’t worry if it wasn’t for the fact that dogs bothering/chasing the cows is a horrible offense in our part of the world, sometimes punishable by death (being shot by the ranchers). We don’t want anything to happen to him, but he can’t always be on a leash. We take him out on one to go potty or to go on a walk, but if he needs to go out and play or run, he can’t be leashed.
We want to teach him that he has to stay in our yard, not the pasture, but Im not sure how to do that. Now, that day, we did get him to come home, and he was scolded and then put for a 5 min time out in his crate and then closely supervised after that. But I would like to feel some assurance that he won’t do it again, the kind of assurance that you get with a well trained dog.
Any suggestions will be appreciated.