Support JPEG textures.

Thanks to Alexander Alexeev (afiskon) for the report.