Fix bug in num_to_bytes

Now the result is correct