Managed to install the OpenJPEG library by following instructions at its website.
Had to update liblcms2-dev, libtiff-dev, libpng-dev etc.
Now running py.test properly.