Зачем такие сложности? Есть же ddjvu -- DjVu decompression utility.
Usage: ddjvu [options] [<djvufile> [<outputfile>]]
Options:
-verbose Prints various informational messages.
-format=FMT Selects output format: pbm,pgm,ppm,pnm,rle,tiff.
-scale=N Selects display scale.
-size=WxH Selects size of rendered image.
-subsample=N Selects direct subsampling factor.
-aspect=no Authorizes aspect ratio changes
-segment=WxH+X+Y Selects which segment of the rendered image
-mode=black Renders a meaningful bitonal image.
-mode=mask Only renders the mask layer.
-mode=foreground Only renders the foreground layer.
-mode=background Only renders the background layer.
-page=PAGESPEC Selects page(s) to be decoded.
-quality=QUALITY Specifies jpeg quality for lossy tiff output.
If <outputfile> is a single dash or omitted, the decompressed image
is sent to the standard output. If <djvufile> is a single dash or
omitted, the djvu file is read from the standard input.