improved bytes conversion method