There have been several visions of dead people, on and off the Island.

This is an attempt to explain them without referencing the Flash Sideways Timeline, which in my opinion was too poorly set up and poorly executed to be taken seriously. The two references to it in the original timeline, Juliet's dying thoughts and Desmond's experiences after being blasted by Widmore, can be explained as the decaying effect of trauma on sanity, or at least on the ability to tell the difference between the material world and the Island's trapped spirits. If the FST must be acknowledged at all, let it be as the dead characters' collective hallucination - if Season 6 had to have the FST, I would have preferred that that season's episodes centred on characters who survived - such as What Kate Does and Everybody Loves Hugo - focused on their real-life time after The End.

1) Man in Black impersonation

a) The Man in Black can only impersonate someone whose dead body is on the Island. This includes Yemi, Locke and Alex, but not Ilana, Sayid or Arzt, whose bodies were disintegrated, or Sun, Jin or Joanna, whose bodies left contact with the Island.

b) The Man in Black impersonated Isabella in the Black Rock. Therefore a part of Isabella's body must have come to the Island, most likely a lock of hair inside Richard's cross.

c) This would explain why the Others have Viking funerals - once a body is in the sea and no longer connected to the Island, the Man in Black cannot impersonate that person. This may have become lost in myth, so that the Others no longer remember why they do it.

d) The Man in Black cannot appear off the main Island.

2) Actual spirit

a) Occasionally the actual spirit of a person has appeared. This includes Charlie, Eko, Ana Lucia to Hurley and Libby to Michael.

b) For this to happen, a person must have died on the Island and part of their body must remain on the Island (Charlie, Eko, Ana, Libby), or they must have committed a murder on the Island (how Michael appeared to Hurley in Everybody Loves Hugo, despite his body being both off-Island and disintegrated). However, dead spirits can appear only to candidates, but they can appear wherever that candidate is, not just on the main island.

3) A visual version of Miles's ability

a) If a candidate has a particularly strong connection to or sense of a person whose remains are on the Island, they can pick up some of that person's most dearly-held ideas.

b) This is how Hurley communicated with Isabella - he was communicating with her residue, not her spirit. This is also how Christian appeared to Jack in hospital in Something Nice Back Home, and how Emily Linus appeared to Ben in The Man behind the Curtain. Roger must have some part of Emily's body stored on the Island - again, most likely a lock of hair in a memento.

4) How to stop this from happening

a) Now that the Man in Black is dead, he will no longer be able to impersonate anyone. However, I believe that the Man in Black was the result of Jacob's brother's mind being imprinted on a pre-existing entity of judgement, which functioned as a material-world Anubis, judging whether a person was fit to live or die, as Ben expected the Monster to do to him in Dead is Dead. This explains both this belief of Ben's and the Ancient Egyptian culture on the Island and referencing the Monster. Mother was likely the last survivor of that culture. Therefore, the smoke monster will still be able to impersonate dead people, and real dead people will still be able to appear to candidates. So how does someone stop this?

b) By either destroying the body that remains on the Island, or by sending it out to sea. One of Walt's primary missions on the Island under Hurley and Ben will be to find and disinter the Island's remaining dead bodies, and then to give them a Viking funeral. This will put them to rest and prevent their spirits from being on the Island and their being impersonated by the Monster.

c) This task will have varying degrees of difficulty. Those characters buried at the beach camp can simply be given Viking funerals (Locke doesn't need one, as he died off the Island), but other characters whose bodies remain on the Island will be harder to find. Daniel's body remains at the Others' camp; Hurley et al will have to ask Richard or Eloise where it's buried. Charlotte's body remains in the jungle and she died in 1867, so by now it will be bones in the jungle. Hurley et al will have to ask if Sawyer or Miles remember where they left Daniel when they went to the Orchid. The most difficult body to remove, though not locate, may well be Charlie's, as to do this, someone will have to break in to the flooded Looking Glass, break into the sealed room where his body is, and remove it via the door (I look on the room's large window as a blooper; in-universe, no human being can enter via it, save perhaps a baby or toddler).

d) Murderers such as Michael will be able to move on only by atoning for their crimes.