Date: 201505
Local time of day: 0001-0600
Location: SBAZ.ARTCC, FO
Flight conditions: VMC
Weather elements / visibility: Turbulence; Thunderstorm
Aircraft: B777 Undifferentiated or Other Model
Operator: Air Carrier
Operating under: Part 121
Flight plan: IFR
Mission: Passenger
Flight phase: Cruise
ATC / advisory: Center SBAZ
Reporter organization: Air Carrier
Reporter function: Pilot Not Flying; Captain
Reporter qualification: Flight Crew Air Transport Pilot (ATP)
Human factors: Situational Awareness
Second reporter function: First Officer; Pilot Flying; Relief Pilot
Anomaly: Deviation - Altitude Excursion From Assigned Altitude; Deviation - Speed All Types; Deviation - Track / Heading All Types; Inflight Event / Encounter Weather / Turbulence
Detector: Person Flight Crew
When detected: In-flight
Result: Air Traffic Control Issued New Clearance; Flight Crew Took Evasive Action
Contributing factors: Aircraft; Weather
Primary problem: Weather

Narrative: I am the Captain and was Pilot Monitoring (PM). The First Officer (FO) was the pilot flying. I called dispatch on Satcom enroute to get an update on weather on our route. The dispatcher mentioned a small speck of weather on the Sat IR approximately 150 miles ahead on our position. We already were looking at that on our radar and started a deviation to the west of course with ATC clearance about 80 miles away.Our current altitude was 39;000; the optimum altitude was 37;900. We were 1;000 above optimum but also 2;900 below Max (41;900). We had selected that altitude as the ride was not good at 35;000 and we were unable to get 37;000 approved earlier.The Weather was on the route at OPLIP intersection; and our Deviation was west of course 60 NM. Time was XA:40Z and we were talking with Amazonica Control. As we approached the cell (still approx. 40 miles off our left) the FO deviated even further to the west to give a wider berth. With the turbulence we had slowed to mach 82. We were about 20 knots above the yellow hook. VNAV was engaged and rather abruptly we both noticed a change in wind direction from a right cross wind of 30 to a headwind of 25. I noticed a sudden change in Total Air Temperature (TAT) temp warmer and then the Pitch Limit Indicators (PLI) displayed on the PFD about 1.5 degrees above our pitch attitude and the speed was decreasing; still above the yellow hook. Engine thrust was now at max Climb we both knew that we would not be able to maintain altitude. The FO asked me about a descent; I said yes descend immediately.I called once to ATC for a clearance and got no reply to our request. I declared a mayday and broadcast our intention to descend to 370. The FO selected 370 and pushed the altitude select button and turned the jet even further from the cell. I suggested a vertical speed descent rather than VNAV.I scanned the engine instruments and EICAS on the descent I notice the temp had gone from -18 to -3. Almost as quickly as we had lost speed in the descent we gained it; and quickly approached max airspeed or the red tape. The FO had his hands full selecting the heading sector and pulling the throttles back some. I used the speed brakes to aid the descent and control speed; after some variable movements in speed from the high to low (all still within the yellow and red bands) we leveled off and maintained 370.I explained our reason for the Mayday call to Amazonica control and got clearance to maintain 370. After passing the weather we were in the clear and returned to the track.We surmised that the temp change put the airplane in a coffin corner situation suddenly and once we got slightly behind the power curve; the aircraft was unable to maintain altitude.I've seen sudden changes in wind speed and direction around thunderstorms and also temps changes; but this was the most significant temp change I've witnessed. We gave this rapidly developing cell (with significant lightning during our passage) at least 20 miles clearance at all times and choose to fly upwind of the cell. But even that was not enough to avoid these atmospheric circumstances prompting our Mayday descent. The Mayday call was to warn ATC and other aircraft of the immediate situation; the outcome of which was never in doubt. [The other] FO was in the bunk and was briefed on the event after our crew change a short period later.Dispatch needs better weather tools for Thunderstorms in Latin South America. They often look at weather and think that not much weather exists and can offer no help to crews in real time. Often causing us to deviate far off course to avoid developing thunderstorms; such as this weather event. Also inflight weather charts and Radar for flight crews in a must in this modern era. Most GA aircraft have much better real time pics of the weather than a $300 M airline aircraft; using hours old paper charts and old electronic data from prior to block out! It's time for real time weather in our flight decks!


Second narrative: [Report Narrative Contained No Additional Information].


Synopsis: A B777 flight crew encounters turbulence at FL390 approaching a thunderstorm over South America. A sudden temperature increase and wind shift make FL390 untenable and a descent is requested. At FL370 the crew is able to maintain airspeed and altitude.