implement conversion from and to byteblock

I also include fix for memory leak for external object destructed in ruby