Typically airliners flying the reverse route will avoid the highest speed jet stream core. They'll usually go north or south of the core to fly against somewhat lower speed headwinds.
You are correct. They can also fly at a higher or lower altitude. The core of the jet stream is about 4,000 feet thick. So changing altitude by that much (or more) up or down can minimize the headwind somewhat.