Fixed bug in __encode()