'Update bitwise flags to reflect new quality values
Check flag bits (clear old then set their new locations) starting
with the highest bits so we dont overwrite data we need later on'

def _update_quality(self, old_quality):

    result = old_quality
    if (result & (1 << 5)):
        result &= (~ (1 << 5))
        result |= (1 << 8)
    if (result & (1 << 4)):
        result &= (~ (1 << 4))
        result |= (1 << 7)
    if (result & (1 << 3)):
        result &= (~ (1 << 3))
        result |= (1 << 5)
    return result
