Your example is too specific to be useful to others, so let's consider the general case instead.
At an untowered field there is no "active" runway - they're all active.
There is usually a "preferred" runway - the one best aligned into the wind - but any runway can be used by any aircraft at any time, subject to whatever safety considerations the pilots mutually agree on. (At untowered fields with intersecting runways that have a lot of training on the field it's not uncommon to have traffic on the crosswind runway intersecting the preferred runway when students need to practice crosswind landings. It can be coordinated safely with a little cooperation between the pilots involved.)
The runway is "changed" by pilots announcing they're using a different runway. There may also be a unicom operator at the field who announces a change in the preferred runway and lets incoming aircraft know about it.
Usually pilots who are already in the pattern for the "old" runway will complete their circuit and land, clearing the runway as expeditiously as possible.
Similarly pilots waiting at the threshold when the wind shifts may elect to either make their takeoff from where they are, or taxi around to the new preferred runway. (In a case where the aircraft must enter the runway to turn around, or where they must back-taxi on the runway this obviously needs to be coordinated with the other pilots. The standard phraseology to use for this is "N12345 back-taxiing on runway XX" )
To your specific example, the directions of traffic patterns don't really matter much: As I mentioned aircraft already in the pattern will probably complete their circuit and land on the runway they were lined up for. Even in the case of Left Traffic for 13 and Right Traffic for 31 and two aircraft maneuvering to enter the pattern for opposite runways the standard pattern entry (45-to-downwind) will tend to keep airplanes apart (they won't ever be heading at each other in the downwind leg if they enter it on the 45, and it should at least ensure they see each other in the opposite-direction 45 and can coordinate to ensure they're never flying at each other). One airplane will probably have to extend their pattern to allow the other to clear the runway safely before they can land, however.
Traffic really should not really be arriving to both downwinds simultaneously anyway, particularly in your example with a single runway: Inbound aircraft should coordinate to arrive in the pattern for the preferred runway.
Aircraft already in the pattern have two choices: Land downwind if safe, or depart the pattern and re-enter it to land on the new preferred runway. A downwind landing must obviously be coordinated with aircraft which may be preparing to depart in the opposite direction.
If landing downwind is unsafe (due to wind speed) or otherwise undesirable (e.g. due to other traffic) climbing above pattern altitude, leaving the area, and returning via a standard pattern entry for the opposite runway is usually the safest course of action.
Aircraft waiting to depart also have two choices: Depart downwind (which must be coordinated with aircraft arriving to the preferred runway), or taxi to the preferred runway end for takeoff. In cases such as you've described where back-taxiing is necessary this must be coordinated with pilots landing (in either direction) as the back-taxiing aircraft will be occupying the runway they need for landing.
The major complicating factor you didn't specifically mention, but which is implied by multiple aircraft "in the pattern" is closed traffic (aircraft making touch-and-go or full-stop/taxi-back landings and immediately taking off again).
Full-Stop/Taxi-Back landings are not a problem: Much like "regular" landing traffic they can land downwind, and upon exiting the runway taxi back to the preferred runway end for their next takeoff.
Touch-and-Go aircraft have two main choices: Land downwind as a full-stop and taxi around to the preferred runway end (which is probably the safest and most considerate thing to do), or complete a touch-and-go with the intention of departing the pattern and returning to set up for circuits to the new preferred runway.
Another important consideration are aircraft without radios (NORDO)- yes, these do exist). A visual scan of the traffic pattern is required at any uncontrolled field at any time to ensure you are not conflicting with NORDO aircraft.
These are often slower planes, so having one in the pattern landing "the wrong way" may require you to wait a while for them to complete their circuit before you can begin operations on the new preferred runway.