Implement toHex() method