Whom to ask to write a reference?
I would reach out to the instructors of the classes you enjoyed the most and put a good effort into, regardless of grade. 

As an instructor myself, I have written recommendations for students who have and who haven't received straight A's - my main requirement for writing a recommendation is can I see this person succeeding in the position I am recommending them for? If not, I let the student know that I am not the right person to write the recommendation for them.

I say reach out to your instructors - the worst they are going to tell you is no.