[#1186] Correctly handle read-only direct ByteBuffer when wrap them

Proposed fix for #1186

@trustin please review