Study of X(3872) in $B$ meson decays