fixed serialize function with bytes not string as argu