added randombytes support on *nix platforms and some error handling for it