Allow to specify custom encoder via block

Fix #253