Avoid potential buffer overrun in bd2str caused by signed char

Use uint8_t to avoid sign extension as char's may be signed.
As a further safeguard, use snprintf()

Change-Id: Icdd4dba9b270bde41547677fa2f98bf215401a23