I have a 100 page PDF that is about 50 MBs. I am running the script below against it and it\'s taking about 23 seconds per page. The PDF is a scan of a paper document.
I may be complete out of place here, but have you given a try to the Djvu file format ? It works like a charm for scanned documents in general (even if there are lots of pictures), and it gives much better compressed files: I get a factor of two lossless gain in size in general on B&W scientific articles.