common: refactor duplicate golomb encoding read/copy routines