If you opened every possible chest, you should have a manual for repairing elevator system and a jail key. After changing into shaman you need to go to a cell with a magic circle (near a cell with a female prisoner - you'll find a way there later). After teleporting you need to transfer power from a lamplike object and find another key. Then you return to the room with earlier similar object and tinker with everything to repair elevator system (rpgs from that circle have too much backtracking). On 2nd floor waits probably hardest battle in the game (it's much easier if you have bought some herbs for curing sleep and confusion).