I had trouble locating your Thomas McKernan, but I think this is your guy. He is in the archives as Thomas McKernon.
There are 9 Thomas McKernon in the records of the Union Army, with three serving from New York. Only one is listed as being a POW. He enlisted at Troy on 12/15-1863,age 40, as a private in the NY 7th Heavy Artillery., Company L (later was transferred to M). He became a prisoner at Petersburg, VA on 6-16-1864, then was released at Savannah, GA on 11-20-1864. He was mustered out of the service in Baltimore, MD on 6-16-1865.
This soldier could not have carried the colors at either of the Bull Run battles, as they were over well before he enlisted. He may have been held temporarily at Libby Prison, but only for a short time, as the Confederates mainly used this for captured officers. Ships frequently departed for Savannah.
There is a book that came out in 1996, "Carnival of Blood: Civil War Ordeal of the 7th NY Heavy Artillery". Author, Robert Keating. I noticed 4 copies for sale at Abebooks, but the cheapest is $215! You might try interlibrary loan first.