I've seen this up close. I'm a software engineer and I've worked for a scientific institute in the past. One of the project involved putting a camera on a helium-filled balloon. The electronics and PC equipment (a PC104-sized Linux box) were powered from a big pack of lithium batteries.
The problem is basically that lithium batteries perform best in a certain temperature range, say from 10 to 25 degrees Celsius (50 to 65 F). But that's rather difficult.When you lift off, it might be cold and you want the batteries to have a decent temperature. Otherwise they can't deliver enough power. So you insulate them and they stay warm by themselves, because when you draw power, they get warm.
But then the higher you lift off into the air, the thinner the air gets. Thus convection will be less and less. You can shed heat via radiation (into the infrared spectrum) but that's only half of the heat or so. And then the insulation can overheat the battery packs.
There's all sorts of tricks, for example copper-strapping the packs to a large piece of black metal so you increase the heat radiation. But if you automate that (or the insulation), you also get additional possible failures.
What it comes down to, is some calculation but also some experience.