integrating external php library into wordpress- the right way

You might want to look into creating a MU (Must Use) plugin, see WordPress Codex. Within this file, you can include your library (using require) or you could just tweak your library file a bit and use it directly as the MU plugin. The session_start() and ob_start() functions worked for me with ever-so-brief testing, but your mileage may vary so test test test 🙂