diff -Nru calibre.orig/src/calibre/ebooks/pdf/images.cpp calibre/src/calibre/ebooks/pdf/images.cpp
--- calibre.orig/src/calibre/ebooks/pdf/images.cpp	2011-04-30 17:48:24.000000000 +0200
+++ calibre/src/calibre/ebooks/pdf/images.cpp	2012-12-23 12:57:00.432159785 +0100
@@ -125,7 +125,7 @@
 
     if (img->type == jpeg) {
         int c;
-        str = ((DCTStream *)str)->getRawStream();
+        str = str->getNextStream();
         str->reset();
 
         // copy the stream
diff -Nru calibre.orig/src/calibre/ebooks/pdf/reflow.cpp calibre/src/calibre/ebooks/pdf/reflow.cpp
--- calibre.orig/src/calibre/ebooks/pdf/reflow.cpp	2012-12-23 12:53:29.336535948 +0100
+++ calibre/src/calibre/ebooks/pdf/reflow.cpp	2012-12-23 12:57:28.503882918 +0100
@@ -625,7 +625,7 @@
   return oss.str();
 }
 
-void XMLOutputDev::process_link(Link* link){
+void XMLOutputDev::process_link(AnnotLink* link){
   double _x1, _y1, _x2, _y2;
   int x1, y1, x2, y2;
   
diff -Nru calibre.orig/src/calibre/ebooks/pdf/reflow.h calibre/src/calibre/ebooks/pdf/reflow.h
--- calibre.orig/src/calibre/ebooks/pdf/reflow.h	2011-04-30 17:48:24.000000000 +0200
+++ calibre/src/calibre/ebooks/pdf/reflow.h	2012-12-23 12:57:53.359637768 +0100
@@ -244,6 +244,6 @@
     XMLImages *images;
     PDFDoc *doc;
 
-    void process_link(Link* link);
+    void process_link(AnnotLink* link);
 };
 }