Fix for the leading zero problem

Does use a trick from
http://dev.enekoalonso.com/2010/07/20/little-tricks-string-padding-in-javascript/
for string padding