It seems as though the matter hasn't been settled and if your ex is incarcerated, he may not have much of a choice in the matter. State laws vary and typically the closer to adulthood a child is, the more likely a judge will grant the request of the child to live with the parent of choice. You may want to speak to an attorney to discuss your options which, in this case, may be to obtain a permanent custody arrangement. Grandparents are usually afforded very few rights.
There are many who give various sorts of advice, e.g. contacting those parties that need to be contacted about the child staying with you. Some also advise contacting the police. Others state that all kinds of third party evaluations/studies also establish a pattern in your favor, e.g. that the child wasn't unduly influenced. I can't tell you what to do. Most attorneys will want to take the matter to court and many advocates will state that this is a needless cost and is best handled at a lower cost by involving neutral third party intermediaries/mediators. I don't think anyone will argue that this is best when there is a mutual agreement of the parties, and perhaps with the ex in jail this could be arranged given your apparent leverage. If you want to establish the arrangment legally, this might be an opportune time to do so.
I'm not sure that this is a situation that you want to begin in a "do it by yourself" fashion since this is not a routine matter and one of primary importance. You may wish to speak to your state bar association for guidance as well as to the county clerk regarding forms and format. They can vary greatly from state to state as do the laws.