Check bytes before decode

May fix #297.