Fixed encdoing bug.

This Pull request will resolve #16 .