The quoted portion in the question, "You got me, partner… Hold me closer, Ed, it's getting dark" contains at least three references. Given that this entire scene is a mishmash of as many classic pop culture references as possible (clearly a must if he wants to win an Oscar for his performance at the end) it's not surprising that he manages to squeeze in multiple references like this.
"You got me partner"
This and the voice being impersonated (both here and in the next two sections) does seem to be an impression of Pat Buttram as noted in the now-removed portion of the Wikipedia article, until he switches to a British accent for the "Tell Tiny Tim…" line. Here's a YouTube video with a number of examples of voices that Pat Buttram did. The line, the costume, and the shootout are clearly a reference to classic Western films but I'm not sure if there's a more specific reference than that.
"Hold me closer"
This is indeed from the 1937 film "A Day at the Races" as pointed out in the other answer. Note, the context is romantic, as opposed to a death scene.
Oh, hold me closer.
Closer. Closer.
If I hold you any closer,
I'll be in back of you.
Source
"Ed, it's getting dark"
This is actually a reference to the sitcom television series, Mister Ed.
In the first season episode "Pageant Show" (1961), Mister Ed (a talking horse) is confronted by Wilbur Post (Alan Young) about a phone being put back in the barn. Ed starts pretending to be dying (ostensibly to avoid having to explain how the phone got back there):
WILBUR: Hey, who phoned the company to put this back? Ed?
ED: It's growing dark. Where is everybody? Is that you mother?
The scene can be viewed in this Dailymotion video at the 20:43 mark. Here's the transcript. This is actually a callback to a similar bit earlier in the same episode where Ed is stalling when Wilbur wants to take him out for a parade.
The use of "getting" instead of "growing" could be a misremembering by the writer (or Carrey if it was just improvised), or it's possible that this was a bit that recurred in other episodes of the show and they had different wording. But it's very common for classic quotes to be misremembered; eg Star Wars' "Luke, I am your father" was actually "No, I am your father". It could be an intentional change in keeping with the mischievous Mask character and the overly emotive, chaotic performance he's putting on. The reference also consists of Ed talking to Wilbur, not someone addressing Ed as is implied by the wording.
The implication of "getting dark" on its own is of course not a reference to nighttime but rather the implication is that he's losing consciousness and dying. Though it flows very nicely into the next line about telling "Auntie Em" (Wizard of Oz reference) to let the dog "Old Yeller" out.