[eluser]toopay[/eluser]
I don't know your whole library looks like and how its flow process. Also is there are loop or nested loop inside your library.
You can working around it with ob_clean(), ob_flush(), proper validation(headers_sent()), save the header in some array variable(apache_response_headers()), and so on. Just make sure you send the header before send out the buffer