Added offset as return value of encode