Fix jpeg filter extensions

Improvement of TheSeeker’s previous pull request #205, including a test case.