The best way out of prison is to comply, work with the legal system, and do your best to keep your head down. Be courteous, respectful, and consistent; this will make your time in prison smoother for everyone.
Going to prison is not easy for anyone involved in the incident. If you want to survive and even thrive afterward, the above really matters.