Fixed an error which causes undefined to be packed as null

When trying to pack undefined, null is packed instead. This commit solves that.