First off, Great Wyrm Red Dragons have 19 caster levels; for spells, it gets to know 2 9th level, 3 each of 6th through 8th level, 4 each of 3rd through 5th level, 5 each of 1st and 2d level, and 9 cantrips.
Why Timestop or Chain Contingency wasn't one of the 9thlevel spells, I honestly don't know. Why harm wasn't in there (cast it, use a NORMAL attack to discharge it, and add 150hp of damage to the blow ...), I also don't know.
Timestop, Prismatic Walls, and a Dimension Lock or two -- lock you in a killing zone
The dragon met you in an area that, apparently, wasn't PREPARED in such a manner as to give it an advantage. I mean, come on; it took the time to lair in an active VOLCANO ... why was there no lava for it to swim through, or knock you into? Why no boulders and such in nets on the cieling, where it's fiery breath could burn the ropes and logs holding them up, dropping the entire mass on your heads?
Bah.
Instead of Fire Giants, frankly, it should have had Iron Golems. Waft a breath attack over them, and it not only damages YOU, it also HEALS the golems!
No offense, but, you should have been lucky to have ONE of your survive, and MAYBE the Dragon was dead. Maybe.