wrap with UMD wrapper so compatible in browser (AMD/non-AMD) and in node.js, fix len & src issues

In order that this module can be used in browser (AMD or non-AMD) and in node.js wrap this in a universal module definition wrapper (see https://github.com/umdjs/umd/blob/master/returnExports.js).

Additional commit was performed to cleanup the formatting and also to fix a couple minor bugs

 - variable len used twice in nested loops, changed to separate vars rlen and clen
 - src undefined in error thrown when no cb supplied