You can hop out of a window to the left (as you look towards the portcullis) and jump along the ledge. You might come across some petrified drow going this route. If so, save!
You can destroy the gem to get out, too.
And I keep thinking there should be some other way to turn off the beams, and that the fact that one beam strikes the altar/font thingy in front of the statue might be relevant. But if there’s something you can put in the font to turn off the beam then I’ve not worked out what. I am bracing myself to feel a right ninny when someone here points out an obvious solution that hasn’t occurred to me!
The key, I think, might open the gate/door to the right when you first enter the temple from above, but I could be wrong about that.