You just need to retrace your step, it's not hard actually. The path mostly is quite linear, but it's hard to explain the detail to escape from the prison.
Around where Agan was, there should be some kind of a hole. Dropping to that hole is a good start to escape. Keep moving around and you'll remember the way eventually.
http://cheats.gbatemp.net/Temp/ i think you have to be a member or something.......... correct me if i am wrong