Most of the dozens of workers killed in an Indonesian factory fire became trapped and died while trying to reach an emergency exit, authorities say.