Improve encoder

raise error when given instance of unsupported class