Improved matching algorithm to avoid unneccesary transcoding (thanks, Liboicl!)
Closes #124.