It was a mirror, not a painting, you're thinking of Provenance with the painting. razz
The Mary in Bloody Mary was (I think) an aspiring actress who was having an affair with a married surgeon. He killed her and cut out her eyes, and with her dying breaths, she tried to spell out his name on the mirror in her blood, but couldn't finish. So her spirit haunted the mirror she died in front of, and whenever she was summoned, she'd find someone with a dark secret, appear in a mirror and get revenge by liquefying their eyes.
I think the writers of the show just invented this story so it'd work in the episode, Sam even mentioned that the Bloody Mary myth has many different origins.