I'll start off by saying that this may be my own perception more than anything else, but it seems like the popular image of cowboys in the American Wild West is predominantly white. This is despite the fact that there were many black and Mexican cowboys, some of them even fairly famous like Nat Love or Bill Pickett. Granted they were not the majority of cowboys, but they seem to be barely represented in cowboy or Wild West imagery.
When did this popular image arise? Did it come up during the time period? Was it maybe a result of the racism and segregation of the 1950s-1960s when movies set in the Wild West were very popular?
The short answer is Dime Novels. Starting in the 1870s, the U.S. (and later Europe) developed a taste for what you might consider the precursor to modern comic books: Dime Novels. These were cheaply made paperback stories that related daring tales of adventure from west of the Mississippi. They began with stories about what are often called "Mountain Men" or scouts, i.e. Kit Carson, but grew into a unique creature all their own by the late 1870s. As this romantic image of the "cowboy" began to take off around this time, the stories shifted to focus more on men on horseback and pistols, etc, which were HUGELY popular. These Dime Novels related stories about white men (civilizing influences) fighting against Native Americans, Mexicans, Jews, Asians, or anyone looking impede the progress of what we now term American Manifest Destiny. This narrative fit the socio-political conversation of the day, and people ate it up. These stories were largely written by white Americans living out east, and catered to a younger white audience that absolutely devoured these things.
As time went on, and public opinion began to shift against railroads and big business, you actually started to see the dynamics of these stories' "hero" change, but not in any racial way (the villains were largely unchanged regardless). For example, after the Panic of 1873, people began to be more and more weary of government and big business influences. This just happened to coincide with what you might call the golden age of outlaws in the American west. Thus, stories started to shift so that outlaws like Jesse James were glorified in these Dime Novels (always Robin Hood-style, stealing from the rich to give to the poor, etc.). What remained the same was the racial and gender dynamics, however. Good guys were white men, women needed to be saved, and anyone not white was not to be trusted all that much. This was obviously done for a reason, as the paying audience was largely white, and those who wrote the stories had, by and large, never been further west that Ohio. They told the stories they thought people wanted to read, and relied on older classic literary tropes that mostly followed this formula (think knight hero and damsel in distress stuff). They also towed the company line of the government at the time, which largely held that the "West" needed to be conquered and civilized for good, white, christian folks. As radio and film took over in the 20th century, they used the source material at hand to adapt proven stories (so, the Dime Novels that were popular), so the all-white hero and minority villain racial dynamic, while not true to life, was the basis for western entertainment in pop culture. Buffalo Bill's Wild West, an immensely popular touring troupe, also played into this racial dynamic with their shows (though not behind the scenes, and less so with gender dynamics).
[Sources: Richard Slotkin, 'Gunfighter Nation' & 'The Fatal Environment'; Michael Denning, 'Mechanic Accents']