ncm-gip2: use write_encoded subroutine suggested by Stijn De Weirdt